<?php

include("connection.php");
$q=$_GET["q"];
$query = "SELECT `name` as caption , `airport_code` as value from `airport_code` WHERE (`airport_code` LIKE '%$q%' OR `name` LIKE '%$q%' )  LIMIT 0,10";
$arr = array();
$rs = mysql_query($query);
$i=0;
while($obj = mysql_fetch_object($rs))
{
    $arr[$i]["caption"] = $obj->caption."(".$obj->value.")";
	$arr[$i]["value"]=$obj->value;
	$i++;
}

echo json_encode($arr);
mysql_close($con);
?>
 